# 1 "video.c"
# 1 "/home/diego/sodium/kernel//"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "video.c"





# 1 "../include/video.h" 1
# 13 "../include/video.h"
# 1 "../include/kernel/definiciones.h" 1
# 14 "../include/kernel/definiciones.h"
# 1 "../include/usr/tipos.h" 1
# 15 "../include/usr/tipos.h"
typedef unsigned int dword;
typedef unsigned short word;
typedef unsigned char byte;

typedef unsigned char u8;
typedef signed char s8;
typedef unsigned short u16;
typedef signed short s16;
typedef unsigned int u32;
typedef signed int s32;


typedef struct _u80 { unsigned int word[20]; } u80;
# 15 "../include/kernel/definiciones.h" 2
# 62 "../include/kernel/definiciones.h"
char stArgAux[128];
# 14 "../include/video.h" 2
# 1 "../include/kernel/libk/string.h" 1
# 9 "../include/kernel/libk/string.h"
inline unsigned char* ucpFnCopiarMemoria(unsigned char *ucpDestino,
      unsigned char *ucpOrigen,
      unsigned int uiTamanio);
inline unsigned char* ucpFnMemSetCero(unsigned char *ucpDirInicio,
                  unsigned int uiTamanio );

int iFnLongitudCadena (const char *cnstCadena);
int iFnCompararCadenas (const char *, const char *);
int iFnCompararCadenas2 (const char *, const char *);
int iFnCopiaCaracter (char *, const char *);
int iFnCopiaCadena (char *, const char *);

int iFnCopiaEntero (char *, const int);
int iFnCopiaFloat (char *, const float, const int);
int iFnCopiaWord (char *, const word);
int iFnCopiaByte (char *, const byte);
int iFnCopiaHexa (char *, const int);
int iFnCopiaWordHexa (char *, const word);
int iFnCopiaByteHexa (char *, const byte);
void vFnImprimirString (char *, const char *, ...);
int iFnLongitudCadena (const char *);

int iFnCopiaCadena2 (char *, const char *);
char * pstFnConcatenarCadena (char * , char * );
int iFnBuscarEnCadena (char * , char * ,int );
char * pstFnCadenaIzquierda (char * , int );
char * pstFnCadenaDerecha (char * , int );
int iFnEsNumero (char * stCadena);

void vFnStrLwr (char * stCadena);
void vFnStrUpr (char * stCadena);
# 15 "../include/video.h" 2
# 58 "../include/video.h"
typedef char* va_list;
# 100 "../include/video.h"
int iFnImprimirCadenas (int,const char*);




void vFnImprimirEntero (int,const int);




void vFnImprimirFloat (int,const double, const int);




void vFnImprimirHexa (int,const int);




void vFnImprimirWordHexa (int,const word);




void vFnImprimirByteHexa (int,const byte);





void vFnImprimirWin (int,const char*, ... );
void vFnImprimir (const char*, ... );
void vFnImprimirI (const char*, ... );

extern char cFnSysObtenerColor(int);
extern void vFnSysSetearColor(int,char);
extern void vFnSysSetearX(int,int);
extern void vFnSysSetearY(int,int);
extern void vFnClsWin(int);





void vFnImprimirContextSwitch(int color,int pid, char* nombre, int indiceGDT);
void vFnImprimirPrompt();
void vFnImprimirOk(int linea);
void vFnImprimirNOk(int linea);

void vFnImprimirVentana (int hVentana, const char *cnstCadena, ...);






int bTerminalActiva;

void vFnCambiarTerminal(void);
void vFnLog (const char *cnstCadena, ...);

void vFnLogScrollArriba();
void vFnLogScrollAbajo();

void vFnLogScrollMaximo();
void vFnLogScrollMinimo();
void vFnLogBorrar();
# 7 "video.c" 2
# 1 "../include/kernel/registros.h" 1
# 15 "../include/kernel/registros.h"
word wFnGetSS();




word wFnGetES();




word wFnGetCS();




word wFnGetDS();




word wFnGetFS();




word wFnGetGS();




dword wFnGetESP();

void vFnLTR(dword);

dword uivFnSTR();
# 8 "video.c" 2
# 1 "../include/kernel/puertos.h" 1
# 26 "../include/kernel/puertos.h"
byte inb(word);
# 38 "../include/kernel/puertos.h"
word inw(word);
# 50 "../include/kernel/puertos.h"
void outb(const byte valor, const word puerto);
# 61 "../include/kernel/puertos.h"
void outw(const word valor, const word puerto);
# 9 "video.c" 2

# 1 "../include/kernel/libk/libk.h" 1
# 15 "../include/kernel/libk/libk.h"
dword dwFnCtod (char *stBuffer);
word wFnCtow (char *stBuffer);
byte byFnCtob (char *stBuffer);

int iFnDwtoBin (unsigned int uiNro, char *cCadenaDevualta);
int iFnDwtoOct (unsigned int uiNro, char *cCadenaDevualta);

void vFnItoa (int iNumero, char *stBuffer);
void vFnItoh (int iNumero, char *stBuffer);

void vFnWtoa (word wNumero, char *stBuffer);
void vFnWtoh (word wNumero, char *stBuffer);

void vFnBtoa (byte byNumero, char *stBuffer);
void vFnBtoh (byte byNumero, char *stBuffer);

int iFnHtoi (char *c);
int iFnCtoi (char *stBuffer);
int iFnXtoi (char *c);

extern void vFnFtoa(char *stBuffer, double fNumero, int iPrecision);
extern double fFnAtof(const char *stBuffer);
# 11 "video.c" 2




extern int iFnSysImprimirCaracter(int, char);
# 30 "video.c"
int iFnImprimirCadena(int hVentana, char *strCadena)
{
 char* strCadInicio = (char*) strCadena;
 while (*strCadena != 0) {
  iFnSysImprimirCaracter(hVentana, *strCadena);
  strCadena++;

 }
 return ((int) ((unsigned char*)strCadena - (unsigned char*) strCadInicio));
}






void vFnImprimirEntero(int hVentana, const int cniNumero)
{

 char stCadena[12];

 vFnItoa(cniNumero, (char *) stCadena);
 iFnImprimirCadena(hVentana, stCadena);

}







void vFnImprimirFloat(int hVentana, const double cnfNumero, const int cniPrecision)
{
 char stCadena[512];







 vFnFtoa((char *) stCadena, cnfNumero, cniPrecision);
 iFnImprimirCadena(hVentana, stCadena);
}






void vFnImprimirWord(int hVentana, const word cnwNumero)
{

 char stCadena[7];

 vFnWtoa(cnwNumero, (char *) stCadena);
 iFnImprimirCadena(hVentana, stCadena);

}






void vFnImprimirByte(int hVentana, const byte cnbyNumero)
{

 char stCadena[7];

 vFnBtoa(cnbyNumero, (char *) stCadena);
 iFnImprimirCadena(hVentana, stCadena);
}







void vFnImprimirHexa(int hVentana, const int cniNumero)
{

 char stCadena[10];

 vFnItoh(cniNumero, (char *) stCadena);
 iFnImprimirCadena(hVentana, stCadena);

}






void vFnImprimirWordHexa(int hVentana, const word cnwNumero)
{

 char stCadena[6];

 vFnWtoh(cnwNumero, (char *) stCadena);
 iFnImprimirCadena(hVentana, stCadena);
}






void vFnImprimirByteHexa(int hVentana, const byte cnbyNumero)
{

 char stCadena[4];

 vFnBtoh(cnbyNumero, (char *) stCadena);
 iFnImprimirCadena(hVentana, stCadena);
}
# 159 "video.c"
void vFnImprimirVentana(int hVentana, const char *cnstCadena, ...)
{
 int iFlags;
 int bInterrupcionesHabilitadas = 0;


 int iCifras;
 int iCifrasDecimales;

 va_list(lista_argumentos);
 ((void) (lista_argumentos = (va_list) &cnstCadena + (((sizeof (cnstCadena) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))));

      __asm__("pushf\n pop %%eax": "=a"(iFlags):);


 if (iFlags & 0x200) {
  __asm__("cli"::);
  bInterrupcionesHabilitadas = 1;
 }


 while (*cnstCadena) {
  if (*cnstCadena == '%') {
   cnstCadena++;

   iCifras = 0;
   while ( *cnstCadena >= '0' && *cnstCadena <= '9') {

    iCifras = iCifras * 10 + *(cnstCadena) - '0';
    cnstCadena++;
   }


   if( *(cnstCadena) == '.' ) {
    cnstCadena++;
                iCifrasDecimales = 0;
    while ( *cnstCadena >= '0' && *cnstCadena <= '9') {
     iCifrasDecimales = iCifrasDecimales*10 +
      *(cnstCadena) - '0';
                    cnstCadena++;
    }
   } else {
                iCifrasDecimales = 6;
            }

   switch (*cnstCadena) {
   case 'c':
    iFnSysImprimirCaracter(hVentana,
             (lista_argumentos += (((sizeof (char) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)), *((char *)(lista_argumentos - (((sizeof (char) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))))));


    break;
   case 'd':
    vFnImprimirEntero(hVentana,
        (lista_argumentos += (((sizeof (int) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)), *((int *)(lista_argumentos - (((sizeof (int) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))))));

    break;
   case 'f':
    vFnImprimirFloat(hVentana,
       (lista_argumentos += (((sizeof (double) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)), *((double *)(lista_argumentos - (((sizeof (double) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))))),iCifrasDecimales);

    break;
   case 'w':
    vFnImprimirEntero(hVentana,
        (lista_argumentos += (((sizeof (word) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)), *((word *)(lista_argumentos - (((sizeof (word) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))))));

    break;
   case 'b':
    vFnImprimirByte(hVentana,
      (lista_argumentos += (((sizeof (byte) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)), *((byte *)(lista_argumentos - (((sizeof (byte) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))))));

    break;
   case 'x':
    cnstCadena++;
    if (*cnstCadena == 'w') {
     vFnImprimirWordHexa(hVentana,
           (lista_argumentos += (((sizeof (word) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)), *((word *)(lista_argumentos - (((sizeof (word) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))))));


    } else if (*cnstCadena == 'b') {
     vFnImprimirByteHexa(hVentana,
           (lista_argumentos += (((sizeof (byte) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)), *((byte *)(lista_argumentos - (((sizeof (byte) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))))));


    } else {
     cnstCadena--;
     vFnImprimirHexa(hVentana,
       (lista_argumentos += (((sizeof (int) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)), *((int *)(lista_argumentos - (((sizeof (int) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))))));


    }
    break;
   case 's':
    iFnImprimirCadena(hVentana,
        (lista_argumentos += (((sizeof (char *) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)), *((char * *)(lista_argumentos - (((sizeof (char *) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))))));

    break;
   }
  } else {
   iFnSysImprimirCaracter(hVentana, *cnstCadena);
  }
  cnstCadena++;
 }
 ((void) (lista_argumentos = 0));

 if (bInterrupcionesHabilitadas)
  __asm__("sti"::);
}
# 278 "video.c"
void vFnImprimir(const char *cnstCadena, ...)
{
 int iFlags;
 int bInterrupcionesHabilitadas = 0;


 int iCifras;
 int iCifrasDecimales;

 va_list(lista_argumentos);
 ((void) (lista_argumentos = (va_list) &cnstCadena + (((sizeof (cnstCadena) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))));

      __asm__("pushf\n pop %%eax": "=a"(iFlags):);


 if (iFlags & 0x200) {
  __asm__("cli"::);
  bInterrupcionesHabilitadas = 1;
 }

 while (*cnstCadena) {
  if (*cnstCadena == '%') {
   cnstCadena++;


   iCifras = 0;
   while ( *cnstCadena >= '0' && *cnstCadena <= '9') {

    iCifras = iCifras * 10 + *(cnstCadena) - '0';
    cnstCadena++;
   }


   if( *(cnstCadena) == '.' ) {
    cnstCadena++;
                iCifrasDecimales = 0;
    while ( *cnstCadena >= '0' && *cnstCadena <= '9') {
     iCifrasDecimales = iCifrasDecimales*10 +
      *(cnstCadena) - '0';
                    cnstCadena++;
    }
   } else {
                iCifrasDecimales = 6;
            }

   switch (*cnstCadena) {
   case 'c':
    iFnSysImprimirCaracter(0,
             (lista_argumentos += (((sizeof (char) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)), *((char *)(lista_argumentos - (((sizeof (char) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))))));


    break;
   case 'd':
    vFnImprimirEntero(0,
        (lista_argumentos += (((sizeof (int) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)), *((int *)(lista_argumentos - (((sizeof (int) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))))));

    break;
   case 'f':
    vFnImprimirFloat(0,
       (lista_argumentos += (((sizeof (double) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)), *((double *)(lista_argumentos - (((sizeof (double) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))))),iCifrasDecimales);

    break;
   case 'w':
    vFnImprimirEntero(0,
        (lista_argumentos += (((sizeof (word) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)), *((word *)(lista_argumentos - (((sizeof (word) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))))));

    break;
   case 'b':
    vFnImprimirByte(0,
      (lista_argumentos += (((sizeof (byte) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)), *((byte *)(lista_argumentos - (((sizeof (byte) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))))));

    break;
   case 'x':
    cnstCadena++;
    if (*cnstCadena == 'w') {
     vFnImprimirWordHexa(0,
           (lista_argumentos += (((sizeof (word) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)), *((word *)(lista_argumentos - (((sizeof (word) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))))));


    } else if (*cnstCadena == 'b') {
     vFnImprimirByteHexa(0,
           (lista_argumentos += (((sizeof (byte) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)), *((byte *)(lista_argumentos - (((sizeof (byte) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))))));


    } else {
     cnstCadena--;
     vFnImprimirHexa(0,
       (lista_argumentos += (((sizeof (int) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)), *((int *)(lista_argumentos - (((sizeof (int) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))))));


    }
    break;
   case 's':
    iFnImprimirCadena(0,
        (lista_argumentos += (((sizeof (char *) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)), *((char * *)(lista_argumentos - (((sizeof (char *) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))))));

    break;
   }
  } else {
   iFnSysImprimirCaracter(0, *cnstCadena);
  }
  cnstCadena++;
 }
 ((void) (lista_argumentos = 0));

 if (bInterrupcionesHabilitadas)
  __asm__("sti"::);
}
# 397 "video.c"
void vFnLog (const char *cnstCadena, ...)
{
  int iFlags;
  int bInterrupcionesHabilitadas = 0;



  int iCifras;
  int iCifrasDecimales;

  va_list (lista_argumentos);
  ((void) (lista_argumentos = (va_list) &cnstCadena + (((sizeof (cnstCadena) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))));

__asm__ ("pushf\n pop %%eax": "=a" (iFlags):);


  if (iFlags & 0x200)
    {
      __asm__ ("cli"::);
      bInterrupcionesHabilitadas = 1;
    }


    vFnLogScrollMinimo();

  while (*cnstCadena)
    {
      if (*cnstCadena == '%')
 {
   cnstCadena++;

   iCifras = 0;
   while ( *cnstCadena >= '0' && *cnstCadena <= '9') {

    iCifras = iCifras * 10 + *(cnstCadena) - '0';
    cnstCadena++;
   }


   if( *(cnstCadena) == '.' ) {
    cnstCadena++;
                iCifrasDecimales = 0;
    while ( *cnstCadena >= '0' && *cnstCadena <= '9') {
     iCifrasDecimales = iCifrasDecimales*10 +
      *(cnstCadena) - '0';
                    cnstCadena++;
    }
   } else {
                iCifrasDecimales = 6;
            }
   switch (*cnstCadena)
     {
     case 'c':
       iFnSysImprimirCaracter (8 ,
          (lista_argumentos += (((sizeof (char) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)), *((char *)(lista_argumentos - (((sizeof (char) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))))));
       break;
     case 'd':
       vFnImprimirEntero (8 , (lista_argumentos += (((sizeof (int) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)), *((int *)(lista_argumentos - (((sizeof (int) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))))));
       break;
     case 'f':
       vFnImprimirFloat (8, (lista_argumentos += (((sizeof (double) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)), *((double *)(lista_argumentos - (((sizeof (double) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))))), iCifrasDecimales);
       break;
     case 'w':
       vFnImprimirEntero (8 , (lista_argumentos += (((sizeof (word) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)), *((word *)(lista_argumentos - (((sizeof (word) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))))));
       break;
     case 'b':
       vFnImprimirByte (8 , (lista_argumentos += (((sizeof (byte) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)), *((byte *)(lista_argumentos - (((sizeof (byte) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))))));
       break;
     case 'x':
       cnstCadena++;
       if (*cnstCadena == 'w')
  {
    vFnImprimirWordHexa (8 ,
           (lista_argumentos += (((sizeof (word) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)), *((word *)(lista_argumentos - (((sizeof (word) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))))));
  }
       else if (*cnstCadena == 'b')
  {
    vFnImprimirByteHexa (8 ,
           (lista_argumentos += (((sizeof (byte) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)), *((byte *)(lista_argumentos - (((sizeof (byte) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))))));
  }
       else
  {
    cnstCadena--;
    vFnImprimirHexa (8 , (lista_argumentos += (((sizeof (int) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)), *((int *)(lista_argumentos - (((sizeof (int) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))))));
  }
       break;
     case 's':
       iFnImprimirCadena (8 , (lista_argumentos += (((sizeof (char *) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)), *((char * *)(lista_argumentos - (((sizeof (char *) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))))));
       break;
     }
 }
      else
 {
   iFnSysImprimirCaracter (8 , *cnstCadena);
 }
      cnstCadena++;
    }
  ((void) (lista_argumentos = 0));

  if (bInterrupcionesHabilitadas)
    __asm__ ("sti"::);
}
# 510 "video.c"
void
vFnImprimirContextSwitch(int iColor, int iPid, char *stNombre,
    int iGDTIndice)
{

 vFnImprimirVentana(1, "\nCSW: PID %d\tTAREA=%s\tINDICE GDT: %d",
      iPid, stNombre, iGDTIndice);
}
# 526 "video.c"
void vFnImprimirPrompt()
{
 vFnImprimir("%s", "\nCmd>");
}
# 540 "video.c"
void vFnImprimirOk(int iLinea)
{
 int iFlags;
 unsigned short int bInterrupcionesHabilitadas = 0;
      __asm__("pushf\n pop %%eax": "=a"(iFlags):);


 if (iFlags & 0x200) {
  __asm__("cli"::);
  bInterrupcionesHabilitadas = 1;
 }

 vFnSysSetearColor(0, 10);
 vFnImprimir("		[ HECHO ] ");
 vFnSysSetearColor(0, 7);

 if (bInterrupcionesHabilitadas)
  __asm__("sti"::);

}






void vFnImprimirNOk(int iLinea)
{
 int iFlags;
 unsigned short int bInterrupcionesHabilitadas = 0;
      __asm__("pushf\n pop %%eax": "=a"(iFlags):);


 if (iFlags & 0x200) {
  __asm__("cli"::);
  bInterrupcionesHabilitadas = 1;
 }

 vFnSysSetearColor(0, 4);
 vFnImprimir("		[ NOK!!!] ");
 vFnSysSetearColor(0, 7);

 if (bInterrupcionesHabilitadas)
  __asm__("sti"::);

}
